package me.illtamer.rpc.test;

import me.illtamer.rpc.api.ByeService;
import me.illtamer.rpc.api.HelloObject;
import me.illtamer.rpc.api.HelloService;
import me.illtamer.rpc.loadbalancer.RandomLoadBalancer;
import me.illtamer.rpc.transport.RpcClientProxy;
import me.illtamer.rpc.transport.socket.client.SocketClient;
import me.illtamer.serializer.CommonSerializer;

/**
 * 测试用客户端启动类
 * */
public class SocketTestClient {

    public static void main(String[] args) {
        SocketClient client = new SocketClient(CommonSerializer.KRYO_SERIALIZER, new RandomLoadBalancer());
        // 接口与代理对象之间的中介对象
        RpcClientProxy proxy = new RpcClientProxy(client);
        HelloService service = proxy.getProxy(HelloService.class);

        HelloObject object = new HelloObject(66, "This is a test message! :)");
        String result = service.hello(object);
        System.out.println(result);
        ByeService byeService = proxy.getProxy(ByeService.class);
        System.out.println(byeService.bye("Netty"));
    }

}
